# Contributor: Sean McAvoy <seanmcavoy@gmail.com>
# Maintainer: Sean McAvoy <seanmcavoy@gmail.com>
pkgname=greetd
pkgver=0.10.0
pkgrel=0
pkgdesc="Minimal and flexible login manager daemon"
url="https://git.sr.ht/~kennylevinsen/greetd"
# riscv64: blocked by cargo
# s390x: no desktop on this arch
arch="all !s390x !riscv64"
license="GPL-3.0-only"
depends="/bin/sh"
makedepends="
	cargo
	cargo-auditable
	linux-pam-dev
	scdoc
	"
install="$pkgname.pre-install"
pkgusers="greetd"
pkggroups="greetd"
subpackages="
	$pkgname-doc
	$pkgname-openrc
	$pkgname-agreety
	"
source="$pkgname-$pkgver.tar.gz::https://git.sr.ht/~kennylevinsen/greetd/archive/$pkgver.tar.gz
	$pkgname.pam
	$pkgname.initd
	$pkgname.confd
	config.patch
	change-default-vt.patch
	"

export RUSTFLAGS="$RUSTFLAGS --remap-path-prefix=$builddir=/build/"

prepare() {
	default_prepare

	cargo fetch --target="$CTARGET" --locked
}

build() {
	cargo auditable build --release --frozen
	make -C man
}

check() {
	cargo check --frozen
}

package() {
	install -Dm755 target/release/greetd -t "$pkgdir"/usr/sbin/
	install -Dm755 target/release/agreety -t "$pkgdir"/usr/bin/

	install -Dm644 config.toml -t "$pkgdir"/etc/greetd/
	install -Dm644 "$srcdir"/$pkgname.pam "$pkgdir"/etc/pam.d/$pkgname

	install -Dm755 "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
	install -Dm644 "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/$pkgname

	make -C man install PREFIX=/usr DESTDIR="$pkgdir"
}

agreety() {
	pkgdesc="Simple, text-based greeter"
	depends="$pkgname=$pkgver-r$pkgrel"

	amove usr/bin/agreety
}

sha512sums="
b2bfbbd4d9fca94ccc623f4f4fc2c3f9518319c96641ecc2c2f10bb6aa8f2b41633b651ed439626971b50c5ad5af5fb8ab5906a46dab158a37395f3cc67a3a21  greetd-0.10.0.tar.gz
896adb033162ffc97cd94cd9f34094600d2789e44e943b8c5d5822dcdbefa063e58f1d00fc07386d1f9eefbbd874996cf75f2bdaf624df8dd057b6676e0f3caf  greetd.pam
425d2cda12d272fd3bf9f03b960cfd421d4391594ddc6220786d45e6c5c563b3aa01644eee01b3078b8a816b34c516f14fe84a4f72cfd94f608d4f5d52310d29  greetd.initd
4e955bc8ba9df6db48f6e86a84af352b550520f39a3945e1fae4a53064bed96b001cf34437199ae03780f72be4125dc65e3ff65704fc67b4addfb738f03c4811  greetd.confd
98ebd6c77c857d5d1d66aea0c5c22669e9af2f6032bcde89f5b08e4c19d3370c3130307c2796a0b42c4695649594964a96999cab8a9d1d8716cdc97637298ddb  config.patch
fb3895d41903cd28952e8642c496b302692b4c35f6b89230fd3746b773f74be561c87a815b622a8914a87285bc715359c7ecadadd3e166ee01b8120326f20ff4  change-default-vt.patch
"
